/*
 * test_client.c
 *
 *  Created on: 2015年10月14日
 *      Author: chens
 */

#include <time.h>
#include "cm_log.h"
int main(int argc, char **argv)
{
    if(argc < 2) {
        printf("Usage: %s <server ip>\n", argv[0]);
        return 0;
    }

    printf("create client.\n");
    int fd = log_client_create(argv[1]);
    printf("fd == %d\n", fd);
    if (fd >= 0) {
        char *buf = NULL;
        int count;
        time_t begin;
        time_t end;

        log_client_write2(argv[1], LOG_INFO, "test message with udp");

        log_client_write(fd, LOG_INFO, "test message");
//
        log_client_query_stat(fd, &count, &begin, &end);
        log_client_query(fd, 0, 4, begin, end, count, &buf);

        if (buf != NULL) {
            printf("Query from server: \n%s\n", buf);
            log_client_freebuf(buf);
        }

//        log_client_download(fd, "local_copy.db");
//

    }
    getchar();

    close(fd);
}

